home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_m_p / pcpwhost.zip / HOST1C.COM / HOSTUTIL.WAS < prev    next >
Text File  |  1992-09-01  |  23KB  |  637 lines

  1. ;Host Mode configuration utility v1.00c
  2.  
  3. ;***********************************************************************
  4. ;*                                                                     *   
  5. ;* HOSTUTIL.WAS                                                        *
  6. ;* Copyright (C) 1992 Datastorm Technologies, Inc.                     *     
  7. ;* All rights reserverd.                                               * 
  8. ;*                                                                     * 
  9. ;* Purpose: A script for creating the HOST.PRM that contains the Host  *
  10. ;*          Mode setup information.  HOSTUTIL also contains the Host   *
  11. ;*          Mail reader.                                               *
  12. ;*                                                                     * 
  13. ;*                                                                     * 
  14. ;***********************************************************************
  15.  
  16. ;***********************************************************************
  17. ;*                                                                     *
  18. ;*  WARNING!!!!                                                        *
  19. ;*                                                                     *
  20. ;*  Do not modify this script file unless you have a good under-       *
  21. ;*  standing of the Windows ASPECT language.  If you do modify this    *
  22. ;*  script, PLEASE MAKE A BACKUP before doing so.                      *
  23. ;*                                                                     *
  24. ;***********************************************************************
  25.  
  26. ;***********************************************************************
  27. ;*                                                                     *
  28. ;*   GLOBAL VARIABLES                                                  *
  29. ;*                                                                     *
  30. ;***********************************************************************
  31.  
  32. string tempfile, line, hdrfile, msgfile, msg_count, recvd, flag, msg
  33. string destination, from, subject, _date, _time, deleted, tempfil2, tempfil1
  34. string welcome_msg, upload_path, dnload_path, filename
  35. integer msg_num ,msg_length, msg_flag, dummy, msg_total
  36. integer blocksize, chars_to_read, msg_number
  37. integer new_usr_level, connect_type, system_type, goodbye_option,status
  38. long offset
  39.  
  40. ;***********************************************************************
  41. ;*                                                                     *   
  42. ;* MAIN                                                                *
  43. ;*                                                                     *
  44. ;* This procedure is ths main program loop.                            *
  45. ;*                                                                     *
  46. ;*                                                                     * 
  47. ;* Calls: HOSTPRM_SAVE, MAIL_MAN                                       *
  48. ;*                                                                     *
  49. ;* Called by: NONE                                                     *
  50. ;*                                                                     *
  51. ;* Modifies globals: filename, welcome_msg, upload_path, dnload_path,  *
  52. ;*                   new_usr_level, connect_type, system_type,         *
  53. ;*                   goodbye_option, status                            *
  54. ;*                                                                     *
  55. ;***********************************************************************
  56. proc main
  57.    fetch aspect scriptpath filename
  58.    addfilename filename "HOST.PRM"
  59.    if isfile filename
  60.       fopen 0 filename READWRITE TEXT
  61.       if not success
  62.          errormsg "Can't open HOST.PRM!"
  63.          halt
  64.       endif
  65.       fgets 0 welcome_msg
  66.       fgets 0 upload_path
  67.       fgets 0 dnload_path
  68.       fgetc 0 new_usr_level
  69.       fgetc 0 connect_type
  70.       fgetc 0 system_type
  71.       fgetc 0 goodbye_option
  72.       fclose 0
  73.    else
  74.       welcome_msg="Welcome to Procomm Plus for Windows Host!"
  75.       fetch dnldpath upload_path
  76.       strupr upload_path
  77.       fetch upldpath dnload_path
  78.       strupr dnload_path
  79.       new_usr_level=2
  80.       connect_type=1
  81.       system_type=1
  82.       goodbye_option=1
  83.       hostprm_save()
  84.    endif
  85.  
  86.    while 1
  87.       dialogbox -33 -1 350 200 11 "Host Mode Utility"
  88.          pushbutton 258 81 40 18 "&Save" update default
  89.          text 6 12 68 8 left "Welcome Message: "
  90.          editbox 77 9 256 13 welcome_msg
  91.          text 13 33 62 8 left "Upload Directory:"
  92.          editbox 77 30 256 13 upload_path
  93.          text 4 55 69 8 left "Download Directory:"
  94.          editbox 77 52 256 13 dnload_path
  95.          groupbox 12 81 90 43 "New User Level"
  96.          radiobutton 22 94 68 10 "0 - Limited User" new_usr_level
  97.          radiobutton 22 108 65 10 "1 - Normal User"  endgroup
  98.          groupbox 133 81 83 43 "Connection Type"
  99.          radiobutton 146 94 42 10 "Modem" connect_type
  100.          radiobutton 146 108 42 10 "Direct"  endgroup
  101.          groupbox 22 130 67 40 "System Type"
  102.          radiobutton 33 141 32 10 "Open" system_type
  103.          radiobutton 33 155 35 10 "Closed"  endgroup
  104.          groupbox 127 131 96 38 "Goodbye Option"
  105.          radiobutton 140 141 47 10 "Recycle" goodbye_option
  106.          radiobutton 140 153 38 10 "Exit"  endgroup
  107.          pushbutton 258 108 40 18 "E&xit" cancel
  108.          pushbutton 236 135 90 18 "&Mail Manager" update
  109.       enddialog
  110.     
  111.       status=$DIALOG
  112.       if $CHILD
  113.          disable CTRL 1
  114.          disable CTRL 31
  115.       endif
  116.       while 1
  117.          switch status
  118.             case 1
  119.                destroydlg
  120.                halt
  121.             endcase
  122.  
  123.             case 30
  124.                hostprm_save()
  125.                if $CHILD
  126.                   destroydlg
  127.                   exit
  128.                endif
  129.                status=0
  130.                loopwhile
  131.             endcase
  132.  
  133.             case 31
  134.                destroydlg
  135.                mail_man()
  136.                exitwhile
  137.             endcase
  138.  
  139.             case 50        ; radio button update
  140.             case 51
  141.             case 52
  142.             case 53
  143.                updatedlg 2
  144.             endcase
  145.          endswitch
  146.          status=$DIALOG
  147.       endwhile
  148.    endwhile
  149. endproc   
  150.  
  151. ;***********************************************************************
  152. ;*                                                                     *   
  153. ;* HOSTPRMSAVE                                                         *
  154. ;*                                                                     *
  155. ;* This procedure saves the HOST.PRM file to disk.                     *
  156. ;*                                                                     * 
  157. ;* Calls: NONE                                                         *
  158. ;*                                                                     *
  159. ;* Called by: 2                                                        *
  160. ;*                                                                     *
  161. ;* Modifies globals: filename, welcome_msg, upload_path, dnload_path,  *
  162. ;*                   new_usr_level, connect_type, system_type,         *
  163. ;*                   goodbye_option                                    *
  164. ;*                                                                     *
  165. ;***********************************************************************
  166. proc hostprm_save
  167.    fopen 0 filename create TEXT
  168.    if not success
  169.       errormsg "Can't open HOST.PRM !"
  170.       halt
  171.    endif
  172.    fputs 0 welcome_msg
  173.    strupr upload_path
  174.    fputs 0 upload_path
  175.    strupr dnload_path
  176.    fputs 0 dnload_path
  177.    fputc 0 new_usr_level
  178.    fputc 0 connect_type
  179.    fputc 0 system_type
  180.    fputc 0 goodbye_option
  181.    fclose 0
  182. endproc
  183.  
  184. ;***********************************************************************
  185. ;*                                                                     *   
  186. ;* MAIL_MAN                                                            *
  187. ;*                                                                     *
  188. ;* This procedure allows the SYSOP to view, delete, and pack the       *
  189. ;* mail message database.                                              *
  190. ;*                                                                     * 
  191. ;* Calls: COUNTMSG, READMSG, DELETEMSG, PACK                           *
  192. ;*                                                                     *
  193. ;* Called by: 1                                                        *
  194. ;*                                                                     *
  195. ;* Modifies globals: hdrfile, msgfile, tempfile, tempfil1, tempfil2,   *
  196. ;*                   msg_total, msg_count, msg_number, msg, status,    *
  197. ;*                   destination, from, subject, recvd, deleted, dummy *
  198. ;*                                                                     *
  199. ;***********************************************************************
  200. proc mail_man
  201. integer number
  202. string input
  203.  
  204.    fetch aspect scriptpath hdrfile
  205.    addfilename hdrfile "HOST.HDR"
  206.     
  207.    fetch aspect scriptpath msgfile
  208.    addfilename msgfile "HOST.MSG"
  209.  
  210.    fetch aspect scriptpath tempfile
  211.    addfilename tempfile "~HOST.TMP"
  212.  
  213.    fetch aspect scriptpath tempfil1
  214.    addfilename tempfil1 "~HOST1.TMP"
  215.  
  216.    fetch aspect scriptpath tempfil2
  217.    addfilename tempfil2 "~HOST2.TMP"
  218.  
  219.    CountMsg(&msg_total)
  220.    if msg_total==0
  221.       errormsg "No messages!"
  222.       return
  223.    endif
  224.    itoa msg_total msg_count
  225.    msg_number=1
  226.  
  227.    dialogbox 0 0 342 214 11 "Host Mail Manager"
  228.       pushbutton 289 6 40 14 "&Next" update default
  229.       pushbutton 289 26 40 14 "&Goto" update
  230.       pushbutton 289 46 40 14 "&Delete" update
  231.       pushbutton 289 65 40 14 "&Pack" update
  232.       pushbutton 289 86 40 14 "E&xit" cancel
  233.       ftext 5 108 328 80 tempfile
  234.       text  2 27 31 8 right "Msg #:"
  235.       vtext 37 27 217 9 left msg
  236.       text  17 44 16 8 right "To:"
  237.       vtext 36 44 81 9 left destination
  238.       text  11 62 23 8 right "From:"
  239.       vtext 37 62 74 9 left from
  240.       text  1 81 35 8 right "Subject:"
  241.       vtext 39 81 146 9 left subject
  242.       text  9 6 56 8 right "Total Messages:"
  243.       vtext 68 6 46 9 left msg_count
  244.       text  185 44 41 8 right "Received:"
  245.       vtext 228 44 37 9 left recvd
  246.       text  158 62 68 8 right "Marked for deletion:"
  247.       vtext 228 62 26 9 left deleted
  248.    enddialog
  249.  
  250.    status=$DIALOG
  251.    status=30
  252.    while status!=1
  253.       switch status
  254.          case 30
  255.             ReadMsg()
  256.          endcase
  257.          case 31
  258.             sdlginput "Goto message" "Enter message number" input
  259.             if success
  260.                atoi input number
  261.                if number>msg_total
  262.                   errormsg "Msg# %d is the last message!" msg_total
  263.                   exitswitch
  264.                endif
  265.                if (number>0) && (number<32768)
  266.                   msg_number=number
  267.                   Readmsg()
  268.                endif
  269.             endif
  270.          endcase
  271.          case 32
  272.             msg_number--
  273.             sdlgmsgbox "Warning!" "Do you want to mark this message for deletion?" QUESTION YESNO dummy BEEP
  274.             if dummy ==6
  275.                DeleteMsg()     ;delete msg
  276.                ReadMsg()
  277.             endif
  278.          endcase
  279.          case 33
  280.             pack()
  281.             CountMsg(&msg_total)
  282.             if msg_total==0
  283.                usermsg "No messages!"
  284.                destroydlg
  285.                return
  286.             endif
  287.             itoa msg_total msg_count
  288.             updatedlg -1
  289.             Readmsg()
  290.          endcase
  291.       endswitch
  292.       status=$DIALOG
  293.    endwhile
  294. endproc
  295.  
  296. ;***********************************************************************
  297. ;*                                                                     *   
  298. ;* READMSG                                                             *
  299. ;*                                                                     *
  300. ;* This procedure opens ans displays a message in a FTEXT box.         *
  301. ;*                                                                     *
  302. ;*                                                                     * 
  303. ;* Calls: NONE                                                         *
  304. ;*                                                                     *
  305. ;* Called by: 4                                                        *
  306. ;*                                                                     *
  307. ;* Modifies globals: hdrfile, msg_number, msg_total, msg_num, offset,  *
  308. ;*                   msg_length, msg_flag, flag, recvd, deleted, from, *
  309. ;*                   destination, dummy, subject, _date, _time, msg,   *
  310. ;*                   msgfile, tempfile, chars_to_read, blocksize, line *
  311. ;*                                                                     *
  312. ;***********************************************************************
  313. proc ReadMsg
  314. long hdr_offset
  315.  
  316.    isfile hdrfile
  317.    if not success
  318.       usermsg "No mail messages!"
  319.       destroydlg
  320.       halt
  321.    else
  322.       fopen 0 hdrfile READWRITE
  323.    endif
  324.  
  325.    if msg_number > msg_total
  326.       msg_number=1
  327.    endif
  328.     
  329.    hdr_offset=(msg_number-1)*128      ; goto a specific record in .HDR file
  330.    fseek 0 hdr_offset 0
  331.     
  332.    fgeti 0 msg_num
  333.    if FEOF 0
  334.       msg_number=1
  335.       return
  336.    endif
  337.    fgetl 0 offset
  338.     
  339.    fgeti 0 msg_length
  340.    fgetc 0 msg_flag
  341.  
  342.    if (msg_flag & 1) ==1
  343.       flag="Private"              ;remove new mail flag
  344.    else
  345.       flag="Public"
  346.    endif
  347.    if (msg_flag & 2) == 2
  348.       recvd="No"
  349.    else
  350.       recvd="Yes"
  351.    endif
  352.    
  353.    if (msg_flag & 4) == 4
  354.       deleted="Yes"
  355.    else
  356.       deleted="No"
  357.    endif
  358.                     
  359.    fread 0 destination 31 dummy
  360.    fread 0 from 31 dummy
  361.    fread 0 subject 37 dummy
  362.    fread 0 _date 9 dummy
  363.    fread 0 _time 11 dummy
  364.  
  365.    fclose 0
  366.  
  367.    strfmt msg "%d  (%s, sent %s at %s)`r`n" msg_num flag _date _time
  368.  
  369.    isfile msgfile
  370.    if not success
  371.       usermsg "No message file!"
  372.       destroydlg
  373.       halt
  374.    else
  375.       fopen 1 msgfile READWRITE text
  376.       if not success
  377.          usermsg "Can't open message file!"
  378.          destroydlg
  379.          halt
  380.       endif
  381.       fopen 2 tempfile create text
  382.       if not success
  383.          usermsg "Can't open temp file!"
  384.          destroydlg
  385.          halt
  386.       endif
  387.  
  388.       fseek 1 offset 1
  389.  
  390.       chars_to_read = msg_length
  391.       while chars_to_read > 0
  392.          if chars_to_read > 128
  393.             blocksize = 128
  394.          else
  395.             blockSize = chars_to_read
  396.          endif
  397.          fread 1 line blocksize dummy
  398.          fwrite 2 line blocksize
  399.          if not success
  400.             errormsg "can't write to temp file!"
  401.             halt
  402.          endif
  403.          chars_to_read = chars_to_read - blocksize
  404.       endwhile
  405.  
  406.       fclose 1
  407.       fclose 2
  408.       updatedlg -1
  409.       delfile tempfile
  410.       inc msg_number
  411.    endif
  412. endproc
  413.  
  414. ;***********************************************************************
  415. ;*                                                                     *   
  416. ;* COUNTMSG                                                            *
  417. ;*                                                                     *
  418. ;* This procedure count the message in the message database.           *
  419. ;*                                                                     *
  420. ;*                                                                     * 
  421. ;* Calls: NONE                                                         *
  422. ;*                                                                     *
  423. ;* Called by: 2                                                        *
  424. ;*                                                                     *
  425. ;* Modifies globals: hdrfile, dummy                                    *
  426. ;*                                                                     *
  427. ;***********************************************************************
  428. proc CountMsg
  429. intparm num
  430. string msg_entry
  431. num=0
  432.  
  433.    fopen 4 hdrfile READ
  434.    if not success
  435.       errormsg "FATAL ERROR - Can't open HOST.HDR file!"
  436.       return
  437.    endif
  438.    while 1
  439.       fread 4 msg_entry 128 dummy
  440.       if FEOF 4
  441.          fclose 4
  442.          return
  443.       endif
  444.       inc num
  445.    endwhile
  446. endproc
  447.  
  448. ;***********************************************************************
  449. ;*                                                                     *   
  450. ;* CHANGEFLAG                                                          *
  451. ;*                                                                     *
  452. ;* This procedure modifies the flag byte for a message.                *
  453. ;*                                                                     *
  454. ;*                                                                     * 
  455. ;* Calls: NONE                                                         *
  456. ;*                                                                     *
  457. ;* Called by: 1                                                        *
  458. ;*                                                                     *
  459. ;* Modifies globals: hdrfile, msg_number                               *
  460. ;*                                                                     *
  461. ;***********************************************************************
  462. proc ChangeFlag
  463. intparm flagbyte
  464. long hdr_offset
  465.  
  466.    fopen 0 hdrfile WRITE
  467.    hdr_offset=((msg_number-1)*128)+8
  468.    fseek 0 hdr_offset 0
  469.    fputc 0 flagbyte
  470.    fclose 0
  471. endproc
  472.  
  473. ;***********************************************************************
  474. ;*                                                                     *   
  475. ;* DELETEMSG                                                           *
  476. ;*                                                                     *
  477. ;* This procedure marks a message for deletion by modifying the        *
  478. ;* flag byte.                                                          *
  479. ;*                                                                     * 
  480. ;* Calls: CHANGEFLAG                                                   *
  481. ;*                                                                     *
  482. ;* Called by: 1                                                        *
  483. ;*                                                                     *
  484. ;* Modifies globals: hdrfile, msg_number, msg_num, offset, msg_length, *
  485. ;*                   msg_flag, destination, dummy, from, subject,      *
  486. ;*                   _date, _time                                      *
  487. ;*                                                                     *
  488. ;***********************************************************************
  489. proc DeleteMsg
  490. long hdr_offset
  491.  
  492.    fopen 0 hdrfile READ
  493.    if not success
  494.       errormsg "FATAL ERROR - Can't open HOST.HDR"
  495.       halt
  496.    endif
  497.  
  498.    hdr_offset=(msg_number-1)*128
  499.    fseek 0 hdr_offset 0
  500.  
  501.    fgeti 0 msg_num
  502.    if FEOF 0
  503.       fclose 0
  504.       return
  505.    endif
  506.    fgetl 0 offset
  507.    fgeti 0 msg_length
  508.    fgetc 0 msg_flag
  509.    fread 0 destination 31 dummy
  510.    fread 0 from 31 dummy
  511.    fread 0 subject 37 dummy
  512.    fread 0 _date 9 dummy
  513.    fread 0 _time 11 dummy
  514.    fclose 0
  515.    msg_flag=msg_flag | 4
  516.    ChangeFlag(msg_flag)
  517. endproc
  518.  
  519. ;***********************************************************************
  520. ;*                                                                     *   
  521. ;* PACK                                                                *
  522. ;*                                                                     *
  523. ;* This procedure compresses the message database by removing mail     *
  524. ;* that is marked for deletion.                                        *
  525. ;*                                                                     * 
  526. ;* Calls:NONE                                                          *
  527. ;*                                                                     *
  528. ;* Called by: 1                                                        *
  529. ;*                                                                     *
  530. ;* Modifies globals: hdrfile, tempfil2, msg_num, msgfile, tempfil1,    *
  531. ;*                   msg_number, offset, msg_length, msg_flag, line    *
  532. ;*                   destination, dummy, from, subject, _date, _time,  *
  533. ;*                   blocksize                                         *
  534. ;*                                                                     *
  535. ;***********************************************************************
  536. proc Pack
  537. long newoffset
  538. integer number=1
  539. integer chars, counter=0
  540.  
  541.    isfile hdrfile
  542.    if not success
  543.       usermsg "No mail messages!"
  544.       halt
  545.    else
  546.       fopen 0 hdrfile READ
  547.       fopen 1 tempfil2 CREATE
  548.    endif
  549.  
  550.    while 1
  551.       fgeti 0 msg_num
  552.       if FEOF 0
  553.          fclose 0
  554.          fclose 1
  555.          delfile "HDR.BAK"
  556.          rename hdrfile "HDR.BAK"
  557.          rename tempfil2 hdrfile
  558.          delfile "MSG.BAK"
  559.          rename msgfile "MSG.BAK"
  560.          rename tempfil1 msgfile
  561.          msg_number=1
  562.          usermsg "%d message(s) deleted!" counter
  563.          return
  564.       endif
  565.  
  566.       fgetl 0 offset
  567.       fgeti 0 msg_length
  568.       fgetc 0 msg_flag
  569.       fread 0 destination 31 dummy
  570.       fread 0 from 31 dummy
  571.       fread 0 subject 37 dummy
  572.       fread 0 _date 9 dummy
  573.       fread 0 _time 11 dummy
  574.  
  575.       if (msg_flag & 4) == 4
  576.          counter++
  577.          loopwhile
  578.       endif
  579.  
  580.       isfile msgfile
  581.       if not success
  582.          usermsg "No message file!"
  583.          halt ;return
  584.       endif
  585.       fopen 2 msgfile READ text
  586.       if not success
  587.          usermsg "Can't open message file!"
  588.          halt  ; return
  589.       endif
  590.       if isfile tempfil1
  591.          fopen 3 tempfil1 WRITE text
  592.          fseek 3 0 2
  593.          ftell 3 newoffset
  594.       else
  595.          fopen 3 tempfil1 CREATE text
  596.          newoffset=0
  597.       endif
  598.       if not success
  599.          usermsg "Can't open temp file!"
  600.          halt ;return
  601.       endif
  602.  
  603.       fseek 2 offset 1
  604.       chars = msg_length
  605.       while chars != 0
  606.          if chars > 128
  607.             blocksize = 128
  608.          else
  609.             blockSize = chars
  610.          endif
  611.          fread 2 line blocksize dummy
  612.          fwrite 3 line blocksize
  613.          if not success
  614.             errormsg "can't write to temp file!"
  615.             halt
  616.          endif
  617.          chars -= blocksize
  618.       endwhile
  619.   
  620.       fclose 2
  621.       fclose 3
  622.  
  623.       fputi 1 number
  624.       fputl 1 newoffset
  625.       fputi 1 msg_length
  626.       fputc 1 msg_flag
  627.       fwrite 1 destination 31
  628.       fwrite 1 from 31
  629.       fwrite 1 subject 37
  630.       fwrite 1 _date 9
  631.       fwrite 1 _time 11
  632.       number++
  633.    endwhile
  634. endproc
  635.  
  636. ;**** End of HOSTUTIL.WAS ****
  637.